<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>task1</title>
</head>
<body>
<div id="condition_select">

    <h3 align="center">日期</h3>


    <div id="select_all" align="center">
                    <select class="form-control" id="date_select">
        <option value="2025-09-13">2025-09-13</option>
        <option value="2018-09-14">2025-09-14</option>
        </select>


    </div>
    <br/>



</div>

<script type="text/javascript" >
function history_query() {
    var date=$('#date_select').val();
    addData(date);
}



// the data table itself
var dataTable = null;

function loadDate(){

        $.getJSON("/json",function (data) {
            var tradeDayList=data.trade_day;
            for (var i=0;i<tradeDayList.length;i++){
                var date=tradeDayList[i];


                var html_str = "<option value='" + date + "'>" + date + "</option>";

                $('#date_select').append(html_str);
            }
        })

    }

jQuery(document).ready(function () {

    loadDate();

      $("#date_select").change(function(){
        history_query();
      });

    dataTable = jQuery("#dataTable").raytable({
        datasource: { data: [], keyfield: 'stock_code' },
        columns: [
            { field: "stock_code", title: "股票代码"},
            { field: "stock_name", title: "股票名称"},
            { field: "total_deal_amount", title: "当日成交总量(万元)",sort:true },
            { field: "zhangfu", title: "涨幅", sort: true },
            // { field: "buy_one", title: "封单(买一)金额(万元)",sort:true  },
            <!--{ field: "lzt_deal_amount", title: "总拉停金额(万元)",sort:true  },-->
            { field: "first_lzt_deal_amount", title: "第一次封板金额(万元)",sort:true  },
            { field: "new_lzt_deal_amount", title: "最后封板金额(万元)",sort:true  },
            { field: "new_lzt_time", title: "最后封板时间"},
            { field: "max_lzt_deal_amount", title: "最大封板金额(万元)",sort:true  },
            { field: "ban_deal_amount", title: "板上总成交金额(万元)",sort:true},
            { field: "float_money", title: "流通市值(亿)",sort:true},
            { field: "ban_deal_rate", title: "板上成交率(%)",sort:true}

        ],
        pagesize: 100,
        maxPageButtons: 5,
        rowNumbers: true

    });

});

function addData(date){

        $.ajax({
            url: "/historyData",
            async: true,
            type:'POST',
            data:JSON.stringify({'date':date}),
            dataType:'json',
            success: function (result) {
                    // var obj = JSON.parse(result);
                    var allInfoList=result.all_info_list;
                    var outputlist=getCondition(allInfoList);
                    doLoad(outputlist);
            },
            error:function (result) {
                var obj=JSON.parse(result.responseText);
                var allInfoList=obj.all_info_list;

                var outputlist=getCondition(allInfoList);
                doLoad(outputlist);
            }
        });
    }

setTimeout(function(){

    var date=$('#date_select').val();
    addData(date);
},100);

// load some data
function doLoad(zhangTingStockInfoData) {
    var zhangTingStockInfoDataTemp=zhangTingStockInfoData;
    for(i=0;i<zhangTingStockInfoDataTemp.length;i++){
        //单位 万元 保留三位

        zhangTingStockInfoDataTemp[i]['total_deal_amount']=(zhangTingStockInfoData[i]['total_deal_amount']/10000).toFixed(3);
        zhangTingStockInfoDataTemp[i]['ban_deal_amount']=(zhangTingStockInfoData[i]['ban_deal_amount']/10000).toFixed(3);
        <!--zhangTingStockInfoDataTemp[i]['lzt_deal_amount']=(zhangTingStockInfoData[i]['lzt_deal_amount']/10000).toFixed(3);-->
        zhangTingStockInfoDataTemp[i]['first_lzt_deal_amount']=(zhangTingStockInfoData[i]['first_lzt_deal_amount']/10000).toFixed(3);
        zhangTingStockInfoDataTemp[i]['new_lzt_deal_amount']=(zhangTingStockInfoData[i]['new_lzt_deal_amount']/10000).toFixed(3);
        zhangTingStockInfoDataTemp[i]['max_lzt_deal_amount']=(zhangTingStockInfoData[i]['max_lzt_deal_amount']/10000).toFixed(3);
        zhangTingStockInfoDataTemp[i]['buy_one']=(zhangTingStockInfoData[i]['buy_one']/10000).toFixed(3);
        //亿
        zhangTingStockInfoDataTemp[i]['float_money']=(zhangTingStockInfoData[i]['float_money']/100000000).toFixed(2);
    }
    dataTable.data(zhangTingStockInfoDataTemp,'stock_code');
}

</script>
</body>
</html>